package top.easycode.app.controller.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.easycode.app.common.BaseReq;
import top.easycode.app.common.BaseRsp;
import top.easycode.app.controller.APPBaseService;
import top.easycode.app.controller.service.dto.req.UserLoginReq;
import top.easycode.app.controller.service.dto.rsp.UserInfoRsp;
import top.easycode.app.service.UserInfoService;
import top.easycode.app.util.DTOUtil;
import top.easycode.app.util.FlectUtil;

/**
 * Created by hujun on 2017\9\30 0030.
 */
@Service
public class UserLoginService extends APPBaseService {
    @Override
    protected BaseReq parseContext(String context, String type) throws Exception {
        return DTOUtil.parseDTO(context, UserLoginReq.class, type);
    }
    @Autowired
    UserInfoService userInfoService;

    @Override
    protected BaseRsp callPscService(BaseReq req, String... params) {
        UserLoginReq userLoginReq = (UserLoginReq) req;
        log.info("------------- 调用userLoginReq接口前参数-------------" + FlectUtil.getFiledsStr(userLoginReq));
        UserInfoRsp userInfoRsp = userInfoService.userLogin(userLoginReq.getName(),userLoginReq.getPassword());
        log.info("------------- 调用userLoginReq接口后参数-------------" + FlectUtil.getFiledsStr(userInfoRsp));
        return userInfoRsp;
    }
}
